<div class="layui-fluid" id="VIEW-list-table" lay-title="流程角色管理">
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" id="addRole">添加角色</div>
                        <div class="layui-btn layui-btn-sm layui-btn-primary table-action" data-type="del">删除</div>
                    </div>
                    <table id="list-table-oagroup" lay-filter="list-table-oagroup"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin', 'table', 'jquery'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , admin = layui.admin;

        var table = layui.table;
        var view = $('#VIEW-list-table');

        var tableFilter = 'list-table-oagroup';

        table.render({
            elem: '[lay-filter="' + tableFilter + '"]',
            //api: 'getGoods',
            url: '/activiti/groupPage?token=' + admin.loginToken,
            height: 'full-165',
            cols: [[
                {title: '', type: 'checkbox', fixed: true, width: 80},
                /*{title: '角色编号', field: 'id', width: 320},*/
                {title: '角色名称', field: 'name', minWidth: 300},
                /*{title: '状态', width: 80, templet: function (d) {
                    var status = {
                        1: {title: '启用', color: 'blue'},
                        0: {title: '禁用', color: 'orange'}
                    }[d.status];
                    return '<span class="layui-badge layui-bg-' + status.color + '">' + status.title + '</span>';
                }},*/
                {title: '操作', width: 350, align: 'center', templet: function (d) {
                    var editBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>';
                    var userBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="userEdit">用户</a>';
                    var delBtn = '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
                    return editBtn + userBtn + delBtn;
                }}
            ]]
        });

        table.on('tool(' + tableFilter + ')', function (obj) {
            if (obj.event === 'del') {//删除行

            } else if (obj.event === "edit") {
                admin.popup({
                    url: '/oa/group/groupEdit',
                    area: ['450px', '250px'],
                    data : {
                        id : obj.data.id,
                        table:table
                    }
                });
                return false
            } else if (obj.event === "userEdit") {
                layui.data('tabData',{key:'id',value:[]});
                admin.popup({
                    url: '/oa/group/groupUserEdit',
                    area: ['680px', '600px'],
                    data : {
                        groupId : obj.data.id,
                        table:table
                    }
                });
                return false
            }
        });

        $("#addRole").on("click", function () {
            admin.popup({
                url: '/oa/group/groupEdit',
                area: ['450px', '250px'],
                data : {
                    table:table
                }
            });
            return false
        });

        view.find('.table-action').click(function () {
            var checkedCount = table.checkStatus(tableFilter).data.length;
            if (checkedCount == 0) {
                layer.msg('请先选择某行');
            } else {
                layer.msg($(this).html() + checkedCount + '项');
            }
        });

    })
</script>